package client;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.util.CharsetUtil;

/**
 * @author dsp
 * @date 2021-04-05
 */
public class NettyHttpClientHandler extends ChannelInboundHandlerAdapter{

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        FullHttpResponse httpResponse = (FullHttpResponse)msg;
        System.out.println("服务端返回headers-> " + httpResponse.headers());
        ByteBuf context = httpResponse.content();
        System.out.println("服务端返回context-> " + context.toString(CharsetUtil.UTF_8));
        context.release();
    }
}
